package com.gun.management.module.member.enums.point;

import cn.hutool.core.util.EnumUtil;
import com.gun.management.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 会员积分的业务类型枚举
 *
 * @author 滚滚
 */
@AllArgsConstructor
@Getter
public enum MemberPointBizTypeEnum implements IntArrayValuable {

    SIGN(95, "签到", "签到获得 {} 积分", true),
    ADMIN(96, "管理员修改", "管理员修改 {} 积分", true),

    INVITE_NEWUSER_POINT(1,"邀请新用户", "增加{}积分", false),
    APP_REVIEW_TASK(2,"应用市场评价", "增加{}积分", false),
    JOIN_ACTIVITY_TASK(3,"参与活动", "增加{}积分", false),
    SHARE_WEIXIN_TASK(4,"分享微信好友", "增加{}积分", false),
    SHARE_FRIEND_TASK(5,"分享朋友圈", "增加{}积分", false),


    INVITE_NEWUSER_REGISTER(6,"邀请新用户注册", "受邀人{}(id:{})完成注册，邀请人奖励{}积分", false),

    INVITE_NEWUSER_REALNAME(7,"邀请新用户实名", "受邀人{}(id:{})完成实名，邀请人奖励{}积分", false),

    INVITE_NEWUSER_GRANT(8,"邀请新用户授信", "受邀人{}(id:{})完成授信，邀请人奖励{}积分", false),

    INVITE_NEWUSER_WITHDRAWAL(9,"邀请新用户提款", "受邀人{}(id:{})完成提款，邀请人奖励{}积分", false),


    LOG_OFF_USER(10,"注销用户", "消耗{}积分", false),

    ORDER_USE(11, "订单积分抵扣", "下单使用 {} 积分", false), // 下单时，扣减积分
    ORDER_USE_CANCEL(12, "订单积分抵扣（整单取消）", "订单取消，退还 {} 积分", true), // ORDER_USE 的取消
    ORDER_USE_CANCEL_ITEM(13, "订单积分抵扣（单个退款）", "订单退款，退还 {} 积分", true), // ORDER_USE 的取消
    OVERDUE_USER_POINT(14,"用户逾期", "扣减{}积分", false),


    ORDER_GIVE(21, "订单积分奖励", "下单获得 {} 积分", true), // 支付订单时，赠送积分
    ORDER_GIVE_CANCEL(22, "订单积分奖励（整单取消）", "订单取消，退还 {} 积分", false), // ORDER_GIVE 的取消
    ORDER_GIVE_CANCEL_ITEM(23, "订单积分奖励（单个退款）", "订单退款，扣除赠送的 {} 积分", false), // ORDER_GIVE 的取消
    BIG_WHEEL(24,"参与大转盘抽奖", "减少{}积分", false),
    NINE_SQUARE_GRID(25,"参与九宫格抽奖", "减少{}积分", false),
    SCRATCH_CARD(26,"参与刮刮卡抽奖", "减少{}积分", false),


    LOTTERY_ADD_POINT(32,"参与抽奖", "中奖增加{}积分", false),

    ;
    // nine-square grid

    // scratch card
    /**
     * 类型
     */
    private final Integer type;
    /**
     * 名字
     */
    private final String name;
    /**
     * 描述
     */
    private final String description;
    /**
     * 是否为扣减积分
     */
    private final boolean add;

    @Override
    public int[] array() {
        return new int[0];
    }

    public static MemberPointBizTypeEnum getByType(Integer type) {
        return EnumUtil.getBy(MemberPointBizTypeEnum.class,
                e -> Objects.equals(type, e.getType()));
    }

}
